import { modules } from "../../gameEngine";

const {ccclass, property} = cc._decorator;

@ccclass
export default class o1Loading extends cc.Component {
    @property(cc.Node)
    ndBg: cc.Node = null;

    @property({type:cc.Node,tooltip:"加载节点"})
    loadingNodes:cc.Node[] = [];


    // LIFE-CYCLE CALLBACKS:

    onLoad() {
        modules().uiControlModule.setGaussianMode(this.ndBg);
    }

    start() {

        this.loadingAni();
        // let mask = this.ndIcon.getChildByName('mask');
        // mask.height = 0;
        // cc.tween(mask)
        //     .then(
        //         cc.tween()
        //             .to(1, {height: 256})
        //             .to(0, {height: 0})
        //     )
        //     .repeatForever()
        //     .start();

        // this.schedule(() => {
        //     this.ndIcon.angle -= 22.5;
        // }, 0.1);
    }

    loadingAni(){
        this.loadingNodes.forEach((n:cc.Node)=>{
            n.active = false;
        });
        this.loadingNodes.forEach((n:cc.Node,index:number)=>{
            this.scheduleOnce(()=>{
                n.active = true;
            },index * 0.2);
        });

        this.scheduleOnce(this.loadingAni,0.8);

    }

    showLoading(text: string) {
        // this.lbLoadText.string = text;
    }

    // update (dt) {}
}
